home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Resources / Developers / XAMPP 1.5.4 / Windows installer / xampp-win32-1.5.4-installer.exe / xampp / php / pear / XML / NITF.php < prev    next >
Encoding:
PHP Script  |  2006-04-07  |  22.8 KB  |  857 lines

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6.  * NITF XML Parser
  7.  *
  8.  * PHP versions 4 and 5
  9.  *
  10.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  11.  * that is available through the world-wide-web at the following URI:
  12.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  13.  * the PHP License and are unable to obtain it through the web, please
  14.  * send a note to license@php.net so we can mail you a copy immediately.
  15.  *
  16.  * @category   XML
  17.  * @package    XML_NITF
  18.  * @author     Patrick O'Lone <polone@townnews.com>
  19.  * @copyright  1997-2005 The PHP Group
  20.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  21.  * @version    CVS: NITF.php,v 1.13 2005/12/09 14:51:04 polone Exp
  22.  * @link       http://pear.php.net/package/XML_NITF/
  23.  */
  24.  
  25. /**
  26.  * Include the XML_Parser class as the base class
  27.  */
  28. require_once ('XML/Parser.php');
  29.  
  30. // {{{ XML_NITF
  31.  
  32. /**
  33.  * Simple NITF Parser
  34.  *
  35.  * This class provides basic NITF parsing. Many of the major elements of the NITF
  36.  * standard are supported. This implementation is based off the NITF 3.1 DTD,
  37.  * publicly available at the following URL:
  38.  *
  39.  * http://www.nitf.org/site/nitf-documentation/nitf-3-1.dtd
  40.  *
  41.  * Note that not all elements of this standard are not supported.
  42.  *
  43.  * <sample>
  44.  * <?php
  45.  * 
  46.  * require_once("XML/NITF.php");
  47.  * 
  48.  * $oNITF =& new XML_NITF();
  49.  * $oNITF->setInputFile("nitf.xml");
  50.  * $xResult = $oNITF->parse();
  51.  * if (PEAR::isError($xResult)) {
  52.  *    die("Parsing failed: ".$xResult->getMessage());
  53.  * }
  54.  * 
  55.  * echo $oNITF->getHeadline();
  56.  * echo $oNITF->getByline();
  57.  * 
  58.  * ?>
  59.  * </sample>
  60.  * 
  61.  * @category   XML
  62.  * @package    XML_NITF
  63.  * @author     Patrick O'Lone <polone@townnews.com>
  64.  * @copyright  1997-2005 The PHP Group
  65.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  66.  * @version    Release: 1.0.2
  67.  * @link       http://pear.php.net/package/XML_NITF
  68.  */
  69. class XML_NITF extends XML_Parser
  70. {
  71.     // {{{ properties
  72.     
  73.     /**
  74.      * Meta tag properties retrieved from document head section
  75.      * @see getMetaData()
  76.      * @var array
  77.      * @access private
  78.      */
  79.     var $m_kMeta = array();
  80.  
  81.     /**
  82.      * Document Metadata
  83.      * 
  84.      * Container for metadata information about this particular document.
  85.      * 
  86.      * @see getDocData()
  87.      * @var array
  88.      * @access private
  89.      */
  90.     var $m_kDocData = array ('key-list' => array ());
  91.  
  92.     /**
  93.      * Specific Publication Data
  94.      * 
  95.      * Information about specific instance of an item's publication. Contains
  96.      * metadata about how the particular news object was used in a specific
  97.      * instance.
  98.      * 
  99.      * @see getPubData()
  100.      * @var array 
  101.      * @access private
  102.      */
  103.     var $m_kPubData = array ();
  104.  
  105.     /**
  106.      * Document Revisions
  107.      * 
  108.      * Information about the creative history of the document; also used as an
  109.      * audit trail. Includes who made changes, when the changes were made, and
  110.      * why. Each element of the array is a key-based array that corresponds to
  111.      * the <revision-history> element.
  112.      * 
  113.      * @var array 
  114.      * @see getRevision()
  115.      * @access private
  116.      */
  117.     var $m_akRevisions = array ();
  118.  
  119.     /**
  120.      * Document Headlines
  121.      * 
  122.      * The various headlines that were found in the document. The headlines are
  123.      * keyed by the levels of HLX. The default hedline (if no level is found) is
  124.      * HL1.
  125.      * @var array
  126.      * @see getHedlines()
  127.      * @access private
  128.      */
  129.     var $m_kHedlines = array ('HL1' => null, 'HL2' => array ());
  130.  
  131.     /**
  132.      * Abstract
  133.      *  
  134.      * Story abstract summary or synopsis of the contents of the document.
  135.      * @var string
  136.      * @access private
  137.      */
  138.     var $m_sAbstract = null;
  139.  
  140.     /**
  141.      * @var string
  142.      * Significant place mentioned in an article. Used to normalize locations.
  143.      * The location in this variable is the place where the story's events will
  144.      * or have unfolded.
  145.      * @access private
  146.      */
  147.     var $m_sLocation = null;
  148.  
  149.     /**
  150.      * @var string
  151.      * Information distributor. May or may not be the owner or creator.
  152.      * @access private
  153.      */
  154.     var $m_sDistributor = null;
  155.  
  156.     /**
  157.      * @var string
  158.      * The elements of the byline, including the author's name and title.
  159.      * @see getByline()
  160.      * @access private
  161.      */
  162.     var $m_kByline = array ('author' => null, 'title' => null);
  163.  
  164.     /**
  165.      * @var array
  166.      * An array of paragraphs extracted from the document
  167.      * @see getLede(), getContent()
  168.      * @access private
  169.      */
  170.     var $m_aContent = array ();
  171.  
  172.     /**
  173.      * @var array
  174.      * A list of media reference elements as found in the body section of the
  175.      * document. Each element is an array itself with keyed properties related
  176.      * to media element in question.
  177.      * @see getMedia()
  178.      * @access private
  179.      */
  180.     var $m_aMedia = array ();
  181.  
  182.     /**
  183.      * @var array
  184.      * A list of tags that were parsed (in order) denoting the current sequence
  185.      * of tags that were parsed. This is array is used for parsing the document
  186.      * elements in a particular order (if needed).
  187.      * @see StartHandler(), EndHandler(), cdataHandler()
  188.      * @access private
  189.      */
  190.     var $m_aParentTags = array ();
  191.  
  192.     /**
  193.      * A byline at the end of a story. Example: Stuart Myles contributed to this
  194.      * article.
  195.      * @var string
  196.      * @see getTagline()
  197.      * @access private
  198.      */
  199.     var $m_sTagline = null;
  200.  
  201.     /**
  202.      * Free-form bibliographic data. Used to elaborate on the source of
  203.      * information.
  204.      * @var string
  205.      * @see getBibliography()
  206.      * @access private
  207.      */
  208.     var $m_sBibliography = null;
  209.  
  210.     // }}}
  211.     // {{{ getDocData()
  212.  
  213.     /**
  214.      * Access all or specific elements of the <docdata> block
  215.      *
  216.      * @param string $sProperty  The property of the <docdata> block to return, the
  217.      *                           most common being:
  218.      *                            +"doc-id" - a unique identifier of this document
  219.      *                            (string)
  220.      *                            +"key-list" - a list of keywords provided with
  221.      *                            the document (array)
  222.      *                            +"copyright" - the copyright holder (string)
  223.      *                            +"series" - if the document is part of series
  224.      *                            (string)
  225.      *                            +"urgency" - a number between 1 (urgent) and 8
  226.      *                            (not urgent) (integer)
  227.      *                            +"date.issue" - date the document was issued
  228.      *                            (UNIX timestamp)
  229.      *                            +"date.release" - date the document is publicly
  230.      *                            available (UNIX timestamp)
  231.      *                            +"date.expires" - date the document is no longer
  232.      *                            valid (UNIX timestamp)
  233.      *
  234.      * @return mixed  All of the elements from the <docdata> block will be returned
  235.      *                if a specific property is not provided. If a specific property
  236.      *                is requested and is found in the docdata block, then that
  237.      *                property will be returned. If the property cannot be found,
  238.      *                null is returned.
  239.      *               
  240.      * @see getDocDataElement()
  241.      * @access public
  242.      */
  243.     function getDocData($sProperty = null)
  244.     {
  245.         if (!empty ($sProperty)) {
  246.  
  247.             $sProperty = strtolower($sProperty);
  248.             if (isset ($this->m_kDocData[$sProperty])) {
  249.  
  250.                 return $this->m_kDocData[$sProperty];
  251.  
  252.             }
  253.             return null;
  254.  
  255.         }
  256.         return $this->m_kDocData;
  257.     }
  258.  
  259.     // }}}
  260.     // {{{ getMetaData()
  261.     
  262.     /**
  263.      * Retrieve meta data from the NITF file
  264.      * @return array Returns an array of key/value pairs from the meta section
  265.      * @access public
  266.      */
  267.     function getMetaData()
  268.     {
  269.         return $this->m_kMeta;
  270.     }
  271.     
  272.     // }}}
  273.     // {{{ getPubData()
  274.  
  275.     /**
  276.      * Returns all elements or a specific element from the <pubdata> block
  277.      *
  278.      * @param string $sProperty The publication property being retrieved
  279.      * @return mixed Returns string, numeric, or array values depending on the
  280.      *         property being accessed from the <pubdata> block.
  281.      *
  282.      * @access public
  283.      */
  284.     function getPubData($sProperty = null)
  285.     {
  286.         if (!empty ($sProperty)) {
  287.  
  288.             $sProperty = strtolower($sProperty);
  289.             if (isset ($this->m_kPubData[$sProperty])) {
  290.  
  291.                 return $this->m_kPubData[$sProperty];
  292.  
  293.             }
  294.             return null;
  295.  
  296.         }
  297.  
  298.         return $this->m_kPubData;
  299.     }
  300.  
  301.     // }}}
  302.     // {{{ getRevision()
  303.  
  304.     /**
  305.      * Get the revision history
  306.      *
  307.      * @return array An array containing key-value arrays. The properties of each
  308.      *               array element in this array are:
  309.      *
  310.      *                 +"comment" - Reason for the revision
  311.      *                 +"function" - Job function of individual performing revision
  312.      *                 +"name" - Name of the person who made the revision
  313.      *                 +"norm" - Date of the revision
  314.      * @access public
  315.      */
  316.     function getRevision()
  317.     {
  318.         return $this->m_akRevisions;
  319.     }
  320.  
  321.     // }}}
  322.     // {{{ getHeadline()
  323.  
  324.     /**
  325.      * Retrieve all headlines or a single headline denoted by key
  326.      *
  327.      * @param integer $nLevel  The key value corresponding to the headline to be
  328.      *                         retrieved
  329.      * @return mixed  Returns an array if no specific headline element is requested,
  330.      *                or a string if the specific headline element requested exists
  331.      * @access public
  332.      */
  333.     function getHeadline($nLevel = 1)
  334.     {
  335.         return $this->m_kHedlines["HL$nLevel"];
  336.     }
  337.  
  338.     // }}}
  339.     // {{{ getByline()
  340.  
  341.     /**
  342.      * Return information about the author of a document
  343.      *
  344.      * @param string $sProperty The field of the byline to retrieve.
  345.      * @return string The entire byline as we found in the document
  346.      * @access public
  347.      */
  348.     function getByline($sProperty = 'author')
  349.     {
  350.         $sProperty = strtolower($sProperty);
  351.         if (isset ($this->m_kByline[$sProperty])) {
  352.  
  353.             return $this->m_kByline[$sProperty];
  354.  
  355.         }
  356.  
  357.         return null;
  358.     }
  359.  
  360.     // }}}
  361.     // {{{ getMedia()
  362.  
  363.     /**
  364.      * Query for a list of related media elements
  365.      *
  366.      * @param string $sProperty  If supplied, only this property will be returned
  367.      *                           for each element of the media reference array.
  368.      * @return array Returns an array of all media reference data, or an array of
  369.      *               select media reference data determined by the property
  370.      *               parameter passed.
  371.      * @access public
  372.      */
  373.     function getMedia($sProperty = null)
  374.     {
  375.         if (empty ($sProperty)) {
  376.  
  377.             return $this->m_aMedia;
  378.  
  379.         } else {
  380.  
  381.             $aMediaRefs = array ();
  382.             foreach ($this->m_aMedia as $aMediaElem) {
  383.  
  384.                 if (isset ($aMediaElem[$sProperty])) {
  385.  
  386.                     array_push($aMediaRefs, $aMediaElem[$sProperty]);
  387.  
  388.                 }
  389.             }
  390.  
  391.             return $aMediaRefs;
  392.  
  393.         }
  394.     }
  395.  
  396.     // }}}
  397.     // {{{ getLede()
  398.  
  399.     /**
  400.      * Returns the lede (sometimes called lead) paragraph
  401.      *
  402.      * @return string Returns the lede paragraph if it is defined, or null otherwise
  403.      * @access public
  404.      */
  405.     function getLede()
  406.     {
  407.         if (isset ($this->m_aContent[0])) {
  408.  
  409.             return $this->m_aContent[0];
  410.  
  411.         }
  412.         return null;
  413.     }
  414.  
  415.     // }}}
  416.     // {{{ getContent()
  417.  
  418.     /**
  419.      * Returns the paragraphs of content
  420.      *
  421.      * @return array An array of elements that represent a single paragraph each
  422.      * @access public
  423.      */
  424.     function & getContent()
  425.     {
  426.         return $this->m_aContent;
  427.     }
  428.  
  429.     // }}}
  430.     // {{{ getTagLine()
  431.  
  432.     /**
  433.      * Returns the tag line (if one exists)
  434.      *
  435.      * @return string The tag line extracted from the NITF data source
  436.      * @access public
  437.      */
  438.     function getTagline()
  439.     {
  440.         return $this->m_sTagline;
  441.     }
  442.  
  443.     // }}}
  444.     // {{{ getBibliography()
  445.  
  446.     /**
  447.      * Returns the free-form bibliographic data
  448.      *
  449.      * @return string The bibliography (if one exists) is returned
  450.      * @access public
  451.      */
  452.     function getBibliography()
  453.     {
  454.         return $this->m_sBibliography;
  455.     }
  456.  
  457.     // }}}
  458.     // {{{ toString()
  459.  
  460.     /**
  461.      * Get a string version of the article
  462.      *
  463.      * @param string  $sCRLF  The character(s) used to separate each article
  464.      *                        element in the string that is returned - often
  465.      *                        referred to as the CRLF.
  466.      * @return string A string representing the main headline, author, content,
  467.      *                and tagline.
  468.      * @access public
  469.      */
  470.     function & toString($sCRLF = "\n")
  471.     {
  472.         $sArticle = "{$this->m_kHedlines['HL1']}$sCRLF";
  473.  
  474.         if (!empty ($this->m_kByline['author'])) {
  475.  
  476.             $sArticle .= "{$this->m_kByline['author']}$sCRLF";
  477.  
  478.         }
  479.  
  480.         if (!empty ($this->m_sLocation)) {
  481.  
  482.             $sArticle .= "{$this->m_sLocation} - ";
  483.  
  484.         }
  485.  
  486.         $sArticle .= join($sCRLF, $this->m_aContent);
  487.  
  488.         if (!empty ($this->m_sTagline)) {
  489.  
  490.             $sArticle .= "$sCRLF{$this->m_sTagline}";
  491.  
  492.         }
  493.  
  494.         return $sArticle;
  495.     }
  496.  
  497.     // }}}
  498.     // {{{ StartHandler()
  499.  
  500.     /**
  501.      * Handle start XML elements and attributes
  502.      *
  503.      * @param object $oParser The XML parser object instance that was inherited
  504.      *                        from the XML_Parser class
  505.      * @param string $sName   A tag element from the XML data stream
  506.      * @param array $kAttrib  An array of XML attributes associated with the given
  507.      *                        tag supplied
  508.      * @return void
  509.      * @access private
  510.      */
  511.     function StartHandler($oParser, $sName, $kAttrib)
  512.     {
  513.         // Push the element into the stack of XML elements already visited
  514.  
  515.         array_push($this->m_aParentTags, $sName);
  516.  
  517.         // Handle the attributes of the XML tags
  518.  
  519.         switch ($sName) {
  520.  
  521.             case 'HL2' :
  522.                 $this->_sHedline = null;
  523.                 break;
  524.  
  525.             case 'P' :
  526.                 if (!empty ($kAttrib['LEDE']) && ($kAttrib['LEDE'] == 'true')) {
  527.  
  528.                     $this->_bIsLede = true;
  529.  
  530.                 }
  531.                 $this->_sContent = null;
  532.                 break;
  533.  
  534.             case 'DOC.COPYRIGHT' :
  535.                 $this->m_kDocData['copyright'] = $kAttrib['HOLDER'];
  536.                 break;
  537.  
  538.             case 'MEDIA' :
  539.                 $this->_kMedia = array ();
  540.                 if (!empty ($kAttrib['MEDIA-TYPE'])) {
  541.  
  542.                     $this->_kMedia['type'] = $kAttrib['MEDIA-TYPE'];
  543.  
  544.                 } else {
  545.  
  546.                     $this->_kMedia['type'] = 'other';
  547.  
  548.                 }
  549.  
  550.                 $this->_kMedia['source'] = null;
  551.                 $this->_kMedia['mime-type'] = null;
  552.                 $this->_kMedia['caption'] = null;
  553.                 $this->_kMedia['data'] = null;
  554.                 $this->_kMedia['encoding'] = null;
  555.                 $this->_kMedia['producer'] = null;
  556.                 $this->_kMedia['meta'] = array ();
  557.                 break;
  558.  
  559.             case 'MEDIA-REFERENCE' :
  560.                 if (!empty ($kAttrib['SOURCE'])) {
  561.  
  562.                     $this->_kMedia['source'] = $kAttrib['SOURCE'];
  563.  
  564.                     // Compatibility with the AP Usenet feed - note that this is a non
  565.                     // standard attribute and is NOT a part of NITF standards
  566.  
  567.                 }
  568.                 elseif (!empty ($kAttrib['DATA-LOCATION'])) {
  569.  
  570.                     $this->_kMedia['source'] = $kAttrib['DATA-LOCATION'];
  571.  
  572.                 }
  573.  
  574.                 $this->_kMedia['mime-type'] = $kAttrib['MIME-TYPE'];
  575.                 break;
  576.  
  577.             case 'MEDIA-OBJECT' :
  578.                 $this->_kMedia['encoding'] = $kAttrib['ENCODING'];
  579.                 break;
  580.  
  581.             case 'MEDIA-METADATA' :
  582.                 if (!empty ($kAttrib['NAME'])) {
  583.  
  584.                     $this->_kMedia[$kAttrib['NAME']] = $kAttrib['VALUE'];
  585.  
  586.                 }
  587.                 break;
  588.  
  589.             case 'PUBDATA' :
  590.                 foreach ($kAttrib as $sKey => $sValue) {
  591.  
  592.                     $this->m_kPubData[strtolower($sKey)] = $sValue;
  593.  
  594.                 }
  595.                 break;
  596.  
  597.             case 'DOC-ID' :
  598.                 $this->m_kDocData['doc-id'] = $kAttrib['ID-STRING'];
  599.                 break;
  600.  
  601.                 // NITF 3.0 extension - added per request by Lars Schenk
  602.                 // (info@lars-schenk.de). Document urgency status information.
  603.  
  604.             case 'URGENCY' :
  605.                 $this->m_kDocData['urgency'] = $kAttrib['ED-URG'];
  606.                 break;
  607.  
  608.                 // The list of keywords or phrases are just added to the array of
  609.                 // keywords.
  610.  
  611.             case 'KEYWORD' :
  612.                 if (empty ($this->m_kDocData['key-list'])) {
  613.  
  614.                     $this->m_kDocData['key-list'] = array ();
  615.  
  616.                 }
  617.  
  618.                 array_push($this->m_kDocData['key-list'], $kAttrib['KEY']);
  619.                 break;
  620.  
  621.                 // The release, expiration, and issuing dates of this article. The
  622.                 // ISO-8601 time stamp settings are preserved, but you can use the
  623.                 // magic function strtotime() to convert these to time stamp values.
  624.  
  625.             case 'DATE.RELEASE' :
  626.             case 'DATE.EXPIRE' :
  627.             case 'DATE.ISSUE' :
  628.                 if (!empty ($kAttrib['NORM'])) {
  629.  
  630.                     $sName = strtolower($sName);
  631.                     $this->m_kDocData[$sName] = $kAttrib['NORM'];
  632.  
  633.                 }
  634.                 break;
  635.  
  636.             case 'REVISION-HISTORY' :
  637.                 array_push($this->m_akRevisions, array_change_key_case($kAttrib, CASE_LOWER));
  638.                 break;
  639.                 
  640.             case 'META':
  641.                 if (!empty($kAttrib['NAME']) && isset($kAttrib['CONTENT'])) {
  642.                     $sName = strtolower($kAttrib['NAME']);
  643.                     $this->m_kMeta[$sName] = $kAttrib['CONTENT'];
  644.                 }
  645.                 break;
  646.  
  647.         }
  648.  
  649.     }
  650.  
  651.     // }}}
  652.     // {{{ EndHandler()
  653.  
  654.     /**
  655.      * Handle XML tag closing state
  656.      *
  657.      * @param object $oParser  The parser object parsing the XML data
  658.      * @param string $sName    The name of the tag element that has just ended
  659.      * @return void
  660.      * @access private
  661.      */
  662.     function EndHandler($oParser, $sName)
  663.     {
  664.         switch ($sName) {
  665.  
  666.             case 'HL1' :
  667.                 $this->m_kHedlines['HL1'] = trim($this->m_kHedlines['HL1']);
  668.                 break;
  669.  
  670.             case 'HL2' :
  671.                 array_push($this->m_kHedlines['HL2'], trim($this->_sHedline));
  672.                 unset ($this->_sHedline);
  673.                 break;
  674.  
  675.             case 'P' :
  676.                 if (isset ($this->_bIsLede)) {
  677.  
  678.                     array_unshift($this->m_aContent, trim($this->_sContent));
  679.                     unset ($this->_bIsLede);
  680.  
  681.                 } else {
  682.  
  683.                     array_push($this->m_aContent, trim($this->_sContent));
  684.  
  685.                 }
  686.                 unset ($this->_sContent);
  687.                 break;
  688.  
  689.             case 'MEDIA' :
  690.                 array_push($this->m_aMedia, $this->_kMedia);
  691.                 unset ($this->_kMedia);
  692.                 break;
  693.  
  694.         }
  695.  
  696.         array_pop($this->m_aParentTags);
  697.     }
  698.  
  699.     // }}}
  700.     // {{{ cdataHandler()
  701.  
  702.     /**
  703.          * Parses CDATA chunks
  704.          *
  705.          * @param object $oParser  The XML parser instance inherited from the
  706.          *                         XML_Parser class
  707.          * @param string $sData    The data chunk to be processed from the parser
  708.          * @return void
  709.          * @access private
  710.          */
  711.     function cdataHandler($oParser, $sData)
  712.     {
  713.         if (!in_array('MEDIA-OBJECT', $this->m_aParentTags)) {
  714.  
  715.             $sData = preg_replace('#\s+#', ' ', $sData);
  716.  
  717.         }
  718.  
  719.         // Elements that can be found in the BODY.HEAD section of the NITF
  720.         // document are defined in this handler.
  721.  
  722.         if (in_array('BODY.HEAD', $this->m_aParentTags)) {
  723.  
  724.             // We don't care if they use other attribute items, we just want the
  725.             // textual version of the byline. Other attributes are appended to
  726.             // the byline data.
  727.  
  728.             if (in_array('BYLINE', $this->m_aParentTags)) {
  729.  
  730.                 if (in_array('BYTTL', $this->m_aParentTags)) {
  731.  
  732.                     $this->m_kByline['title'] .= $sData;
  733.                     return;
  734.  
  735.                 }
  736.  
  737.                 $this->m_kByline['author'] .= $sData;
  738.                 return;
  739.  
  740.             }
  741.  
  742.             // Generally, the distributor is the same as the company supplying
  743.             // the content. However, this is not always the case (the AP, for
  744.             // example).
  745.  
  746.             if (in_array('DISTRIBUTOR', $this->m_aParentTags)) {
  747.  
  748.                 $this->m_sDistributor .= $sData;
  749.                 return;
  750.  
  751.             }
  752.  
  753.             // The location where the story pertains too.
  754.  
  755.             if (in_array('DATELINE', $this->m_aParentTags)) {
  756.  
  757.                 if (in_array('LOCATION', $this->m_aParentTags)) {
  758.  
  759.                     $this->m_sLocation .= $sData;
  760.  
  761.                 }
  762.                 return;
  763.             }
  764.  
  765.             // There are only two possibilities for hedlines, the main headline
  766.             // or a subheadline.
  767.  
  768.             if (in_array('HEDLINE', $this->m_aParentTags)) {
  769.  
  770.                 if (in_array('HL2', $this->m_aParentTags)) {
  771.  
  772.                     $this->_sHedline .= $sData;
  773.  
  774.                 } else {
  775.  
  776.                     $this->m_kHedlines['HL1'] .= $sData;
  777.  
  778.                 }
  779.  
  780.             }
  781.             return;
  782.  
  783.         }
  784.  
  785.         // The article content, including the lead and following paragraphs, can
  786.         // be found in this section of the XML document.
  787.  
  788.         if (in_array('BODY.CONTENT', $this->m_aParentTags)) {
  789.  
  790.             if (in_array('MEDIA', $this->m_aParentTags)) {
  791.  
  792.                 // The media caption for the currently selected media element.
  793.  
  794.                 if (in_array('MEDIA-CAPTION', $this->m_aParentTags)) {
  795.  
  796.                     $this->_kMedia['caption'] .= $sData;
  797.                     return;
  798.  
  799.                 }
  800.  
  801.                 if (in_array('MEDIA-OBJECT', $this->m_aParentTags)) {
  802.  
  803.                     $this->_kMedia['data'] .= $sData;
  804.                     return;
  805.  
  806.                 }
  807.  
  808.             }
  809.  
  810.             // A paragraph element was found.
  811.  
  812.             if (in_array('P', $this->m_aParentTags)) {
  813.  
  814.                 $this->_sContent .= $sData;
  815.                 return;
  816.  
  817.             }
  818.  
  819.         }
  820.  
  821.         // The <body.end> tag has two primary elements, <taglines> and the free
  822.         // form <bibliography> tags.
  823.  
  824.         if (in_array('BODY.END', $this->m_aParentTags)) {
  825.  
  826.             if (in_array('TAGLINE', $this->m_aParentTags)) {
  827.  
  828.                 $this->m_sTagline .= $sData;
  829.                 return;
  830.  
  831.             }
  832.  
  833.             if (in_array('BIBLIOGRAPHY', $this->m_aParentTags)) {
  834.  
  835.                 $this->m_sBibliography .= $sData;
  836.  
  837.             }
  838.  
  839.         }
  840.  
  841.     }
  842.  
  843.     // }}}
  844.  
  845. }
  846.  
  847. // }}}
  848.  
  849. /*
  850.  * Local variables:
  851.  * tab-width: 4
  852.  * c-basic-offset: 4
  853.  * c-hanging-comment-ender-p: nil
  854.  * End:
  855.  */
  856.  
  857. ?>